<!--1819.1 User Profile Page-- User profile template-->
{% extends "base.html" %}

{% block content %}
    <!-- 1819.2 insert the avatar images, first td tag ; add table, tr, td-->
    <table>
        <tr valign="top">
            <td><img src="{{ user.avatar(128) }}"></td>
            <td>
                <!---->
                <h1>User: {{ user.username }}</h1>
                <!--1819.4 More Interesting Profiles, add these two new fields to the user profile template-->
                {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
                {% if user.last_seen %}<p>Last seen on: {{ user.last_seen }}</p>{% endif %}
                 <!--202122.7 在用户个人资料页面中添加 关注、取消关注的链接; 显示有多少粉丝，关注了多少人-->
                 <p>{{ user.followers.count() }} followers, {{ user.followed.count() }} following.</p>
                 <!--1819.6 add profile editor link in user user profile page-->
                 {% if user == current_user %}
                    <p><a href="{{ url_for('edit_profile') }}">Edit your profile</a></p>
                     <!--202122.7 在用户个人资料页面中添加关注、取消关注的链接；豆约翰的代码简单；用户不是当前用户时，如果当前用户未关注用户，显示“关注”，否则显示未关注-->
                 {% elif not current_user.is_following(user) %}
                <p>
                    <a href="{{ url_for('follow', username=user.username) }}">Follow</a>
                </p>

				{% else %}
					<p>
						<a href="{{ url_for('unfollow', username=user.username) }}">Unfollow</a>
					</p>
                {% endif %}
            </td>
        </tr>
    </table>
    <hr>
    {% for post in posts %}
        <!--1819.3 Using Jinja2 Sub-Templates-->
		{% include '_post.html' %}
	{% endfor%}
{% endblock %}